﻿//  --------------------------------
//  Copyright (c) Bernard White. All rights reserved.
//  This source code is made available under the terms of the Microsoft Public License (Ms-PL)
//  http://mocklet.codeplex.com/license
//  ---------------------------------

using System;
using System.Management.Automation;
using Mocklet.Data;

namespace Mocklet.Commands
{
    [Cmdlet(Verbs.Mock, "Person")]
    public sealed class MockPerson : Cmdlet
    {
        #region Fields

        private int _Number = 1;

        #endregion Fields

        #region Parameters

        [Parameter(Position = 0, HelpMessage = "The number of persons to return.")]
        public int Number
        {
            get { return this._Number; }
            set { this._Number = value; }
        }

        #endregion Parameters

        protected override void ProcessRecord()
        {
            //if (this._Number < 1 || this._Number > 10000)
            //{

            //}

            Random r = new Random();

            Person[] result = new Person[this._Number];

            for (var i = 0; i < this._Number; i++)
            {
                result[i] = r.NextPerson();
            }

            this.WriteObject(result, true);
        }
    }
}
